package saeildamil.ch18.critical;

public class SharedAccount {
	Account leeAccount;		//이몽룡계좌
	Account sungAccount;	//성춘향계좌
	
	synchronized void transfer(int amount){
		 	try {
				leeAccount.withdraw(amount);
				System.out.println("이몽룡 계좌:100만원 인출");
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
			sungAccount.deposit(amount);
			System.out.println("성춘향 계좌:100만원 입금");
		}
	
	synchronized int getTotal() {
		return leeAccount.balance + sungAccount.balance;

	}
}
